<template>
  <div>
    <Child :title="title" @onClick = "getName" ref="child"/>
    {{ param }}
    {{ child?.name }}
  </div>
  <button @click="open">触发子组件方法</button>
</template>

<script setup lang=ts>
import Child from './Child1.vue';
import {ref} from "vue"

const child = ref<InstanceType<typeof Child>>()
  const open =  ()=>{
    child.value?.open()
    param.value = child.value?.name
    
  }


const title = ref<string>("父组件传的标题")
  const param = ref<string>();
  const getName = (str:string)=>{
    param.value = str
    console.log("接收到的子组件值: ",str);
    
  }

</script>

<style scoped>
</style>